import java.util.Scanner;

public class hw3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("n:");
        int n = scanner.nextInt();
        System.out.println("1！+2！+3！+4！+........+n! 当n="+n+"时结果为"+facSum(n));
    }
    public static int facSum (int n) {
        int sum = 0;
        for (int j = 1; j <= n ; j++) {
            int ret = 1;
            for (int i = 1; i <= j; i++) {
                ret *= i;
            }
            sum += ret;
        }
        return  sum;
    }
}
